package second.greedy;

import java.util.Arrays;

public class Solution03 {
    public int wiggleMaxLength(int[] nums) {
        int res = 1;
        int cur;
        int pre = 0;
        for (int i = 1; i < nums.length; i++) {
            cur = nums[i] - nums[i - 1];
            if ((cur > 0 && pre <= 0) || (cur < 0 && pre >= 0)) {
                res++;
                pre = cur;
            }
        }
        return res;
    }
}

